//模拟下拉框开始
function simu_select(option){
	var that = this;
	that.obj = option.obj;
	that.trig = that.obj.find(".select-trig");
	that.pop = that.obj.find(".select-pop");
	that.trig.bind({
		click:function(event){
			event.stopPropagation();
			that.allhide();
			var _this = $(this);
			that.thiscont = _this.find(".select-is");
			that.thisobj = $(this).parent(".m-select");
			that.thispop = $(this).siblings(".select-pop");
			that.thispop.css({"display":"block"});
			that.thisobj.css({"z-index" : 51});
			that.thispop.bind({
				click : function(event){
					event.stopPropagation();
					var target = $(event.target);
					var cont = target.html();
					//赋值
					_this.parent().prev("input").val(target.attr("cvalue"));
					that.thiscont.html(cont);
					//提示框
					var _tips = _this.parent().siblings("span").last();
					_tips.html("");
					_tips.removeClass().addClass("form-tips form-tips-ok");
					that.allhide();
				}
			});
		}
	});
	$(document).bind({
		click : function(event){
			that.allhide();
		}
	});
}
simu_select.prototype = {
	allhide : function(){
		var that = this;
		that.pop.css({"display":"none"});
		that.obj.css({"z-index" : 50});
	}
};

//模拟下拉框结束
$(function(){
	new simu_select({
		obj : $(".m-select")
	});
});